﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using l1cs.server.model.Instance;
using l1cs.server.serverpackets;
using l1cs.server.model;

namespace l1cs.server.clientpackets
{
    public class C_Ship : ClientBasePacket
    {
        private const String _C_SHIP = "[C] C_Ship";
        private static Logger _log = Logger.getLogger( typeof( C_Ship ).FullName );

        public C_Ship( byte[] abyte0, ClientThread client )
            : base( abyte0 )
        {

            int shipMapId = readH();
            int locX = readH();
            int locY = readH();

            L1PcInstance pc = client.getActiveChar();
            int mapId = pc.getMapId();

            if ( mapId == 5 )
            { // Talking Island Ship to Aden Mainland
                pc.getInventory().consumeItem( 40299, 1 );
            }
            else if ( mapId == 6 )
            { // Aden Mainland Ship to Talking Island
                pc.getInventory().consumeItem( 40298, 1 );
            }
            else if ( mapId == 83 )
            { // Forgotten Island Ship to Aden Mainland
                pc.getInventory().consumeItem( 40300, 1 );
            }
            else if ( mapId == 84 )
            { // Aden Mainland Ship to Forgotten Island
                pc.getInventory().consumeItem( 40301, 1 );
            }
            else if ( mapId == 446 )
            { // Ship Hidden dock to Pirate island
                pc.getInventory().consumeItem( 40303, 1 );
            }
            else if ( mapId == 447 )
            { // Ship Pirate island to Hidden dock
                pc.getInventory().consumeItem( 40302, 1 );
            }
            pc.sendPackets( new S_OwnCharPack( pc ) );
            L1Teleport.teleport( pc, locX, locY, (short)shipMapId, 0, false );
        }

        override
        public String getType()
        {
            return _C_SHIP;
        }
    }
}